package com.stock.demo.util;

/**
 * Created by XuZhaoyu on 2017/7/23.
 */

public class SettingUtils {

    public static final int SPEED_VERY_FAST = 1000;
    public static final int SPEED_FAST = 3000;
    public static final int SPEED_MEDIUM = 5000;
    public static final int SPEED_SLOW = 8000;
    public static final int SPEED_VERY_SLOW = 10000;

    public static boolean checkAutoLogin() {
        Object objAutoLogin = CacheUtils.get().getAsObject(Constants.KEY_AUTO_LOGIN);
        return objAutoLogin != null && (boolean) objAutoLogin;
    }

    public static void setAutoLogin(boolean autoLogin) {
        CacheUtils.get().put(Constants.KEY_AUTO_LOGIN, autoLogin);
    }

    public static boolean checkForceRefresh() {
        Object objForceRefresh = CacheUtils.get().getAsObject(Constants.KEY_FORCE_REFRESH);
        return objForceRefresh != null && (boolean) objForceRefresh;
    }

    public static void setForceRefresh(boolean forceRefresh) {
        CacheUtils.get().put(Constants.KEY_FORCE_REFRESH, forceRefresh);
    }

    public static void setRefreshSpeed(int speed) {
        CacheUtils.get().put(Constants.KEY_REFRESH_SPEED, speed);
    }

    public static int getRefreshSpeed() {
        Object objRefreshSpeed = CacheUtils.get().getAsObject(Constants.KEY_REFRESH_SPEED);
        if (objRefreshSpeed == null) {
            return SPEED_MEDIUM;
        } else {
            return (int) objRefreshSpeed;
        }
    }

}
